$(function () {
	$("#jqGrid").jqGrid({
		url: baseURL + '/manage/withdrawList',
		datatype: "json",
		colModel: [         
		{ label: 'ID', name: 'id', width: 30, key: true },
		{ label: '用户 ', name: 'username', width: 100 },
		{label:"账户类型",name:"type",width: 50},
		{label:"提现账号",name:"account",width: 60},
		{label:"提现金额",name:"sum",width: 40},
		{ label: '提交时间', name: 'createTime', width: 100,formatter: function(value, options, row){
			return  parseTime(value);
		}},

		{label:"状态",name:"status",width: 40,formatter: function(value, options, row){
			if(value==0){  return  "待转账";}
			else if (value==1) {return "已转账";}

		}},
		{ label: '操作', name: 'status', width: 80, formatter: function(value, options, row){
			if (value==0){
				return '<span class="btn btn-info" onclick="transfer('+row.id+')">转账</span>';    
			}else{
                return '<span >已转账</span>';
            }

		}},
		],
		viewrecords: true,
		height: 555,
		rowNum: 10,
		rowList : [10,30,50],
		rownumbers: true, 
		rownumWidth: 25, 
		autowidth:true,
		multiselect: true,
		pager: "#jqGridPager",
		jsonReader : {
			root: "data.dataList",
			page: "data.currentPage",
			records: "data.totalNum",
            total: "data.total"
		},
		prmNames : {
			page:"data.total",
			rows:"pageSize", 
			order: "order"
		},
		gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});
function transfer(id){
	confirm("您确认已经转账了吗？",function () {
        var data={
            "id":id
        }
        $.ajax({
            url: baseURL + "/manage/transfer",
            type: 'POST',
            data: JSON.stringify(data),
            dataType: 'JSON',
            cache: false,
            processData: false,
            contentType: "application/json",
            success: function(r){
                if (r.code===0) {
                	alert(r.info,function () {
						location.reload();
                    })
                    // var page = $("#jqGrid").jqGrid('getGridParam','page');
                    // $("#jqGrid").jqGrid('setGridParam',{
                    //     page:page
                    // }).trigger("reloadGrid");
                }else{
                    alert(r.info,function () {
						location.reload();
                    });
                }

            }
        });
    })

};

var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			key: null
		},
		showList: true,
		title: null
	},
	methods: {
		reload: function () {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{ 
				postData:{'key': vm.q.key},
				page:page
			}).trigger("reloadGrid");
		}
	}
});